package com.zxy.study.ui.widget.custom;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.TextView;

import androidx.annotation.Nullable;

/**
 * @author : Shonn.Zhang
 * @email : shonn.zhang@mart.blue
 * @time : 2020/9/29 18:10
 * @desc :
 */
public class CustomTextView extends androidx.appcompat.widget.AppCompatTextView {

    private static final String TAG = "CUS_CustomTextView";

    public CustomTextView(Context context) {
        super(context);
    }

    public CustomTextView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        boolean widthExactly = MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY;
        boolean heightExactly = MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.EXACTLY;

        Log.i(TAG, "onMeasure: widthExactly=" + widthExactly + " width=" + MeasureSpec.getSize(widthMeasureSpec) + " heightExactly=" + heightExactly + "  height=" + MeasureSpec.getSize(heightMeasureSpec));
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        Log.i(TAG, "onLayout: changed=" + changed+" ["+left+","+top+","+right+","+bottom+"]");
        super.onLayout(changed, left, top, right, bottom);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        Log.i(TAG,"onDraw:");
        super.onDraw(canvas);
    }

}
